-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
ci: Bring back MDX caching with public folder cache #14187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Bundle ReportChanges will increase total bundle size by 863.85kB (4.09%) ⬆️. This is within the configured threshold ✅ Detailed changes
ℹ️ *Bundle size includes cached data from a previous commit Affected Assets, Files, and Routes:view changes for bundle: sentry-docs-server-cjsAssets Changed:
Files in
App Routes Affected:
view changes for bundle: sentry-docs-client-array-pushAssets Changed:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR restores MDX caching by writing compressed cache files and cached assets to a .next/cache/mdx-bundler directory and switches from the React cache helper to an in-memory Map for per-process caching.
- Adds Brotli‐compressed cache read/write functions and cache directory setup
- Wraps image bundler output into a cache directory and reuses it on CI
- Replaces
reactcache with a simpleMapforgetFileBySlugWithCache
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/mdx.ts | Implements cache directory, compression, and in-process cache |
| scripts/generate-md-exports.mjs | Guards against undefined response.Contents when iterating |
Comments suppressed due to low confidence (1)
src/mdx.ts:67
- [nitpick] Consider adding unit tests for
readCacheFileandwriteCacheFileto validate that cache files are correctly compressed, decompressed, and handled under CI conditions.
async function readCacheFile<T>(file: string): Promise<T> {
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Cache Writing Fails on Missing Directory
The cp operation, used for copying assets to the public directory during cache writing, throws an uncaught error if its source directory (assetsCacheDir) does not exist. This occurs when esbuild processes MDX files that do not generate any assets, as esbuild only creates the output directory when it has files to write. This uncaught error causes the getFileBySlug function to fail, potentially crashing the build process. Unlike the cache reading logic, the cache writing logic does not gracefully handle the absence of this directory.
src/mdx.ts#L684-L685
Lines 684 to 685 in 377a562
| if (assetsCacheDir && cacheFile) { | |
| await cp(assetsCacheDir, outdir, {recursive: true}); |
Was this report helpful? Give feedback by reacting with 👍 or 👎
Old version ignored the assets put under `public/mdx-images` causing missing images. This version fixes the issue and brings build times back down to around 11 minutes. May need a cache-busting redeploy once this merges (seen issues on `develop-docs`) but once we do that, the errors should go away. --------- Co-authored-by: Copilot <[email protected]>
Old version ignored the assets put under
public/mdx-imagescausing missing images. This version fixes the issue and brings build times back down to around 11 minutes.May need a cache-busting redeploy once this merges (seen issues on
develop-docs) but once we do that, the errors should go away.